﻿@{
    ViewBag.Title = "上传文档";
   
}
<script src="~/Content/js/jquery-plugin/fineuploader-3.7.1/jquery.fineuploader-3.7.1.min.js"></script>
<script>
    $(document).ready(function () {
        var sId = '@ViewBag.FileId';
        //        $('#fine-uploader').fineUploader({
        //            request: { endpoint: '/api/qms/FileContent/postfile?id=' + sId },
        //            multiple: false,    //设成false，这样就不能多选了，只能选一个
        //            validation: {
        //                allowedExtensions: ['doc', 'docx', 'xls','xlsx'],
        //                sizeLimit: 51200000 // 5000 kB = 50000 * 1024 bytes
        //            },
        //            text: { uploadButton: '请选择文件...' },
        //            autoUpload: true
        //        }).on('upload', function (id, name) {
        //            $.messager.progress({ title: '请稍等', msg: '正在上传...', interval: 0 });
        //        }).on('complete', function (event, id, name, response) {
        //            //上传成功
        //            $.messager.progress('close');
        //            if (response.success) {
        //                com.message('success', response.message);
        //                //刷新
        //            }
        //        }).on('progress', function (target, id, name, loaded, total) {
        //            $.messager.progress('bar').progressbar('setValue', Math.ceil(loaded * 100 / total));
        //            if (loaded >= total) {
        //                $.messager.progress('close');
        //                $.messager.progress({ title: '请稍等', msg: '上传完成，正在导入处理...', interval: 300, text: '' });
        //            }
        //        }).on('error', function (target, id, name, reason, maybeXhrOrXdr) {
        //            //com.message('error', reason);
        //        });
        var uploader = new qq.FineUploader({
            element: document.getElementById('fine-uploader'),
            request: { endpoint: '/api/qms/FileContent/postfile',
                params: {
                    Id: sId
                }
            },
            text: {
                uploadButton: '选择上传文件' //上传按钮的文字
            },
            multiple: true, //是否为多文件上传
            validation: {
                allowedExtensions: [], //限制上传格式 'doc', 'docx', 'xls', 'xlsx', 'txt'
                sizeLimit: 1024 * 1024 * 1024 * 1024 * 1024 //限制上传大小 
            },
            autoUpload: false, //是否自动提交 
            editFilename: {    //编辑名字 
                enable: false
            },
            showMessage: function (message) {
                // Using Bootstrap's classes
                //$('#fine-uploader').append('<div class="alert alert-error">' + message + '</div>');
                com.message('error', "格式不正确!");
            },
            callbacks: {
                onComplete: function (id, fileName, responseJSON) {
                    //上传成功
//                    if (responseJSON.success) {
//                        com.message('success', responseJSON.message);
//                    }
//                    else {
//                        com.message('error', responseJSON.message);
//                    }

                }
            },
            debug: true
        });
        //确定事件
        document.getElementById('triggerUpload').onclick = function () {
            uploader.uploadStoredFiles();
        };
    });
</script>
<!-- Fine Uploader CSS
====================================================================== -->
<link href="~/Content/js/jquery-plugin/fineuploader-3.7.1/fineuploader-3.7.1.css"
    rel="stylesheet" type="text/css" />
<!-- Fine Uploader DOM Element
====================================================================== -->
<div id="fine-uploader">
</div>
<div style="text-align: center; margin: 5px;">
    <a id="triggerUpload" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">确定</a>
    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" data-bind="click:cancelClick"
        href="javascript:void(0)">取消</a>
</div>
<!-- Fine Uploader template
====================================================================== -->
@*  <script type="text/template" id="qq-template">
  <div class="qq-uploader-selector qq-uploader">
      <div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
          <span>Drop files here to upload</span>
      </div>
      <div class="qq-upload-button-selector qq-upload-button">
          <div>Upload a file</div>
      </div>
      <span class="qq-drop-processing-selector qq-drop-processing">
          <span>Processing dropped files...</span>
          <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
      </span>
      <ul class="qq-upload-list-selector qq-upload-list">
          <li>
              <div class="qq-progress-bar-container-selector">
                  <div class="qq-progress-bar-selector qq-progress-bar"></div>
              </div>
              <span class="qq-upload-spinner-selector qq-upload-spinner"></span>
              <span class="qq-edit-filename-icon-selector qq-edit-filename-icon"></span>
              <span class="qq-upload-file-selector qq-upload-file"></span>
              <input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
              <span class="qq-upload-size-selector qq-upload-size"></span>
              <a class="qq-upload-cancel-selector qq-upload-cancel" href="#">Cancel</a>
              <a class="qq-upload-retry-selector qq-upload-retry" href="#">Retry</a>
              <a class="qq-upload-delete-selector qq-upload-delete" href="#">Delete</a>
              <span class="qq-upload-status-text-selector qq-upload-status-text"></span>
          </li>
      </ul>
  </div>
</script>*@ 